<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCertificationTable extends Migration
{
    public function up()
    {
        //邮箱认证
        Schema::create('certification_email', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->comment('用户ID');
            $table->string('email')-> comment('邮箱');
            $table->tinyInteger('status')->default(0)-> comment('认证状态 等待验证=0 通过验证=1');
            $table->string('token',32)-> comment('认证令牌');
            $table->timestamp('end_time')-> comment('令牌有效期');
            $table->timestamps();
        });
	    //个人认证
	    Schema::create('certification_personal', function (Blueprint $table) {
		    $table->increments('id');
		    $table->unsignedInteger('user_id')->comment('用户ID');
		    $table->string('name')->comment('姓名');
		    $table->string('type')->comment('证件类型 身份证=1 护照=2 港澳居民来往内地通行证=3 台湾居民来往大陆通行证=4 外国人永久居留身份证=5 港澳居民居住证=6 台湾居民居住证=7 军官证=8 其他=9');
		    $table->string('number')->comment('证件号码');
		    $table->string('image1')->comment('正面照片 url');
		    $table->string('image2')->nullable() ->comment('反面照片 url');
		    $table->tinyInteger('status')->default(0)-> comment('认证状态 等待验证=0 通过验证=1 验证失败=-1');
		    $table->timestamps();
	    });
	    //企业认证
	    Schema::create('certification_company', function (Blueprint $table) {
		    $table->increments('id');
		    $table->unsignedInteger('user_id')->comment('用户ID');
		    $table->string('name')->comment('企业名称');
		    $table->string('type')->comment('证件类型');
		    $table->string('number')->comment('证件号码');
		    $table->string('image1')->comment('正面照片 url');
		    $table->string('image2')->nullable() ->comment('反面照片 url');
		    $table->tinyInteger('status')->default(0)-> comment('认证状态 等待验证=0 通过验证=1 验证失败=-1');
		    $table->timestamps();
	    });
    }

    public function down()
    {
        Schema::dropIfExists('certification_email');
        Schema::dropIfExists('certification_personal');
        Schema::dropIfExists('certification_company');
    }
}
